package org.seed.quantum.example.ssl;

import org.seed.quantum.example.api.DemoApi;
import org.seed.quantum.example.api.DemoApiImpl;
import org.seed.quantum.message.plugins.SslPlugin;
import org.seed.quantum.message.rpc.RpcProviderProcessor;
import org.seed.quantum.message.ssl.SslAuthEnum;
import org.seed.quantum.protocol.RpcProtocol;
import org.seed.quantum.socket.SocketServer;

import java.io.IOException;

public class RpcProviderDemo {

    public static void main(String... args) throws IOException {
        RpcProviderProcessor rpcProviderProcessor = new RpcProviderProcessor();
        SslPlugin sslServerPlugin = new SslPlugin(null);
        sslServerPlugin.initForServer(RpcConsumerDemo.class.getClassLoader().getResourceAsStream("server.keystore"), "123456", "123456", SslAuthEnum.OPTIONAL);
        rpcProviderProcessor.addPlugin(sslServerPlugin);
        SocketServer server = new SocketServer(8888, new RpcProtocol(), rpcProviderProcessor);
        server.start();

        rpcProviderProcessor.publishService(DemoApi.class, new DemoApiImpl());
    }

}
